/*
 * Copyright (c) 2009, Servoy-stuff
 * 
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 * http://www.fsf.org/licensing/licenses/lgpl.txt
 */
package net.stuff.servoy.beans.dnd;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;

import javax.swing.border.Border;

import com.servoy.j2db.IApplication;
import com.servoy.j2db.IServoyBeanFactory;
import com.servoy.j2db.plugins.IClientPluginAccess;
import com.servoy.j2db.ui.IComponent;
import com.servoy.j2db.util.Debug;

/**
 * @author Servoy Stuff
 * http://www.servoy-stuff.net/
 */
public class DnDFileBean implements IServoyBeanFactory {

	private DnDFileChooser component = new DnDFileChooser();
	private Border border;
	private Color background;
	private Color foreground;
	private Font font;
	private Point location;
	private Dimension size;
	private boolean opaque = true;
	private boolean visible = true;
	private String name;
	private String toolTipText;
	private String titleText;
	private String onDrop;
	private String onOmit;
	private String popupOmitString = "Omit";
	private String accept;
	private boolean recurseFolders;
	
	/* (non-Javadoc)
	 * @see com.servoy.j2db.IServoyBeanFactory#getBeanInstance(int, com.servoy.j2db.plugins.IClientPluginAccess, java.lang.Object[])
	 */
	public IComponent getBeanInstance(int appMode, IClientPluginAccess app, Object[] paramArrayOfObject) {
		if (appMode == IApplication.HEADLESS_CLIENT || appMode == IApplication.WEB_CLIENT) {
			Debug.error(this.getClass().getSimpleName()+" is not web-client compatible: It will do nothing more!");
			return null;
		}
		component.setApp(app);
		component.init();
		return component;
	}

	/**
	 * @return the toolTipText
	 */
	public String getToolTipText() {
		return toolTipText;
	}

	/**
	 * @param s
	 */
	public void setToolTipText(String s) {
		toolTipText = s;
		if (component != null)
			component.setToolTipText(s);
	}

    /* (non-Javadoc)
     * @see com.servoy.j2db.persistence.Zdb#getName()
     */
    public String getName() {
		return name;
    }

    /**
     * @param s
     */
    public void setName(String s) {
        name = s;
        if(component != null)
        	component.setName(s);
    }

    /**
     * @return the border
     */
    public Border getBorder() {
		return border;
    }

    /**
     * @param border
     */
    public void setBorder(Border border) {
        this.border = border;
        if (component != null)
        	component.setBorder(border);
    }

    /**
     * @return the foreground
     */
    public Color getForeground() {
		return foreground;
    }

    /**
     * @param color
     */
    public void setForeground(Color color) {
        foreground = color;
        if (component != null)
        	component.setForeground(color);
    }

    /**
     * @return the background
     */
    public Color getBackground() {
		return background;
    }

    /**
     * @param color
     */
    public void setBackground(Color color) {
        background = color;
        if (component != null)
        	component.setBackground(color);
    }

    /**
     * @return
     */
    public Font getFont() {
		return font;
    }

    /**
     * @param font
     */
    public void setFont(Font font) {
        this.font = font;
        if (component != null)
        	component.setFont(font);
    }

    /**
     * @return the location
     */
    public Point getLocation() {
		return location;
    }

    /**
     * @param point
     */
    public void setLocation(Point point) {
        location = point;
        if (component != null)
        	component.setLocation(point);
    }

    /**
     * @return the size
     */
    public Dimension getSize() {
		return size;
    }

    /**
     * @param dimension
     */
    public void setSize(Dimension dimension) {
        size = dimension;
        if (component != null)
        	component.setSize(dimension);
    }

    /**
     * @param rectangle
     */
    public void setBounds(Rectangle rectangle) {
        setLocation(rectangle.getLocation());
        setSize(rectangle.getSize());
    }

	/**
	 * @return the visible
	 */
	public boolean isVisible() {
		return visible;
	}

	/**
	 * @param visible the visible to set
	 */
	public void setVisible(boolean visible) {
		this.visible = visible;
		if (component != null)
			component.setComponentVisible(visible);
	}

	/**
	 * @return the opaque
	 */
	public boolean isOpaque() {
		return this.opaque;
	}

	/**
	 * @param opaque the opaque to set
	 */
	public void setOpaque(boolean opaque) {
		this.opaque = opaque;
		if (component != null)
			component.setOpaque(opaque);
	}

	/**
	 * @return the onDrop
	 */
	public String getOnDrop() {
		return this.onDrop;
	}

	/**
	 * @param onDrop the onDrop to set
	 */
	public void setOnDrop(String onDrop) {
		this.onDrop = onDrop;
		if (component != null)
			component.setOnDrop(onDrop);
	}

	/**
	 * @return the onOmit
	 */
	public String getOnOmit() {
		return this.onOmit;
	}

	/**
	 * @param onOmit the onOmit to set
	 */
	public void setOnOmit(String onOmit) {
		this.onOmit = onOmit;
		if (component != null)
			component.setOnOmit(onOmit);
	}

	/**
	 * @return the popupOmitString
	 */
	public String getPopupOmitString() {
		return this.popupOmitString;
	}

	/**
	 * @param popupOmitString the popupOmitString to set
	 */
	public void setPopupOmitString(String popupOmitString) {
		this.popupOmitString = popupOmitString;
		if (component != null)
			component.setPopupOmitString(popupOmitString);
	}

	/**
	 * @return the recurseFolders
	 */
	public boolean isRecurseFolders() {
		return this.recurseFolders;
	}

	/**
	 * @param recurseFolders the recurseFolders to set
	 */
	public void setRecurseFolders(boolean recurseFolders) {
		this.recurseFolders = recurseFolders;
		if (component != null)
			component.setRecurseFolders(recurseFolders);
	}

	/**
	 * @return the titleText
	 */
	public String getTitleText() {
		return this.titleText;
	}

	/**
	 * @param titleText the titleText to set
	 */
	public void setTitleText(String titleText) {
		this.titleText = titleText;
	}

	/**
	 * @return the accept
	 */
	public String getAccept() {
		return accept;
	}

	/**
	 * @param accept the accept to set
	 */
	public void setAccept(String accept) {
		this.accept = accept;
		if (component != null)
			component.setAccept(accept);
	}

}
